﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace UnitTestCommon.Msg
{
    [TestClass]
    public class UnitTestLog
    {
        [TestInitialize]
        public void initMethod()
        {
            string baseDir = System.AppDomain.CurrentDomain.BaseDirectory;
            Common.Msg.Log.GetLog.InitConfigByFile(System.IO.Path.Combine(baseDir, "log4net.config"), "testLog", "UnitTestCommon", "0.2", "localhosttest");
        }
        [TestMethod]
        public void TestMethod1()
        {
            Common.Msg.Log.GetLog.Info("我就是随便写一条消息", new { id = 101 });
            Common.Msg.Log.GetLog.Debug("加一条", typeof(UnitTestLog));
            try
            {
                Common.Msg.Log.GetLog.Warn("警告,我要开始报错了");
                int i = 1;
                int res = (i - 1) / 0;
            }
            catch (Exception ex)
            {
                Common.Msg.Log.GetLog.Error("测试一下2", new { i = 1 }, ex);
            }
            Common.Msg.Log.GetLog.Fatal("都结束了...", DateTime.Now);
        }
    }
}
